package com.xl6667.controller;

import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.entity.Link;
import com.xl6667.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/link")
public class SysLinkController {
    @Autowired
    private LinkService linkService;

    /**
     * 获取所有Link
     * @param pageNum
     * @param pageSize
     * @param name
     * @param status
     * @return
     */
    @GetMapping("/list")
    public ResponseResult listLink(Integer pageNum,Integer pageSize,String name,String status){
        return linkService.listLink(pageNum,pageSize,name,status);
    }

    /**
     * 添加Link
     * @param link
     * @return
     */

    @PostMapping
    public ResponseResult addLink(@RequestBody Link link){
        return linkService.addLink(link);
    }

    /**
     * 回显Link
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public ResponseResult getLink(@PathVariable Long id){
        return linkService.getLink(id);
    }

    /**
     * 修改Link
     * @param link
     * @return
     */
    @PutMapping
    public ResponseResult putLink(@RequestBody Link link){
        return linkService.putLink(link);
    }

    /**
     * 修改友链状态
     * @param link
     * @return
     */
    @PutMapping("/changeLinkStatus")
    public ResponseResult changeStatusLink(@RequestBody Link link){
        return linkService.changeStatusLink(link);
    }
    /**
     * 删除友链
     */
    @DeleteMapping("{ids}")
    public ResponseResult delLink(@PathVariable List<Long> ids){
        return linkService.delLink(ids);
    }



}
